#include "../syntax_tree.h"
#include <stdio.h>

void syntax_print(syntax_t tree)
{
	syntax_node * node=syntax_get_content(tree);
	syntax_node * child_node;
	syntax_t child_tree;
	int i;
	if (tree==NULL)
		{
			return;
		}
	printf ("%c has %d partment \n",node->type,node->pno);
	for(i=0;i<node->pno;i++){
		child_tree=syntax_get_partment(tree,i);
		child_node=syntax_get_content(child_tree);
		printf ("%c\t",child_node->type);
	}
	printf ("\n");

	for (i=0; i<node->pno; ++i)
		{
			syntax_print(syntax_get_partment(tree,i));
		}
	
}

int main(int argc, char *argv[])
{
    syntax_t tree1=syntax_create('1',0);
	syntax_t tree2=syntax_create('2',0);
	syntax_t tree =syntax_create('+',2,tree1,tree2);
	tree =syntax_create('+',2,tree,syntax_create('2',0));
	
	syntax_print(tree);
	
    return 0;
}
